<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
  components: {},
  data() {
    return {
      appWindow: window,
      editVisible: true,
      //消费时间
      consumeTime: "",
      //注册时间
      createdTime: "",
      //成为会员时间
      levelTime: "",


      // 导出文件的数据
      exportData: {
        nickName: {
          type: String,
          value: "",
          default: "",
        },
        // 手机号
        mobile: {
          type: String,
          value: "",
          default: "",
        },
        // 客户编号
        memberCode: {
          type: String,
          value: "",
          default: "",
        },
        // 消费起始金额
        consumeAmountStart: {
          type: Number,
          value: null,
          default: null,
        },
        // 消费截止金额
        consumeAmountEnd: {
          type: Number,
          value: null,
          default: null,
        },
        // 消费起始次数
        consumeCountStart: {
          type: Number,
          value: null,
          default: null,
        },
        // 消费截止次数
        consumeCountEnd: {
          type: Number,
          value: null,
          default: null,
        },
        // 最近消费开始时间
        consumeTimeStartStr: {
          type: String,
          value: null,
          default: null,
        },
        // 最近消费结束时间
        consumeTimeEndStr: {
          type: String,
          value: null,
          default: null,
        },
        // 注册开始时间
        createdTimeStartStr: {
          type: String,
          value: null,
          default: null,
        },
        // 注册结束时间
        createdTimeEndStr: {
          type: String,
          value: null,
          default: null,
        },
        // 性别
        gender: {
          type: Number,
          value: null,
          default: null,
        },
        // 成为会员时间
        levelTimeStartStr: {
          type: String,
          value: null,
          default: null,
        },
        // 成为会员结束时间
        levelTimeEndStr: {
          type: String,
          value: null,
          default: null,
        },
        // 可用起始金额
        usableAmountStart: {
          type: Number,
          value: null,
          default: null,
        },
        // 可用截止金额
        usableAmountEmd: {
          type: Number,
          value: null,
          default: null,
        },
        // 售后起始次数
        saleAfterCountStart: {
          type: Number,
          value: null,
          default: null,
        },
        // 售后截止次数
        saleAfterCountEnd: {
          type: Number,
          value: null,
          default: null,
        },
        // 售后起始金额
        saleAfterAmountStart: {
          type: Number,
          value: null,
          default: null,
        },
        // 售后截止金额
        saleAfterAmountEnd: {
          type: Number,
          value: null,
          default: null,
        },
        // 用户标签ID集合
        tagIdLst: {
          type: [],
          value: null,
          default: null,
        },
      },
    };
  },

  methods: {
    // 初始化
    async init() {},
    // 导出报表
    async exportTable() {
      let dataObj_ = {};
      for (const key in this.exportData) {
        dataObj_[key] = this.exportData[key].value;
      }

      let res = await this.$vFN.Http.post(
        {
          url: "mall-site-portal/member/exportMemberList",
          data: dataObj_,
        },
        window
      );

      if (res._ok) {
        this.$vFN.Tools.messageSuccess("操作成功，请到下载中心查看");
        this.editVisible = false;
      }
    },

    // 时间选择
    timeSelection(vaule, timeStartStr, timeEndStr){

     if(this.$vFN.Utils.isEmpty(vaule)){
           timeStartStr.value = "";
           timeEndStr.value ="";
      }else{
        // 开始时间
        timeStartStr.value = value[0];
        // 结束时间
        timeEndStr.value = value[1];
      }
    
    },

    // 清空导出筛选
    clearExport() {
      for (const key in this.exportData) {
        this.exportData[key].value = this.exportData[key].default;
      }

      this.consumeTime = "";
      this.createdTime = "";
      this.levelTime   = "";
    },

    // 提交成功
    onSubmitSuccess() {
      this.onSuccess();
    },
    // 成功回调
    onSuccess() {},
    // 取消回调
    onCancel() {},
    // 失败回调
    onError() {},
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>